package com.yueka.controller;

import com.yueka.pojo.R;
import com.yueka.pojo.entity.student.Student;
import com.yueka.service.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/web")
@RestController
public class WebController {
    @Autowired
    private WebService webService;

    @GetMapping("/getBannerList")
    public R getBanners() {
        try {
            return R.success(webService.getBanners());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getActivityWebList")
    public R getActivityWebList() {
        try {
            return R.success(webService.getActivityWebList());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getTeacherList")
    public R getTeacherList() {
        try {
            return R.success(webService.getTeacherList());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getInstrumentList")
    public R getInstrumentList() {
        try {
            return R.success(webService.getInstrumentList());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getHonorList")
    public R getHonorList() {
        try {
            return R.success(webService.getHonorList());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getExperienceList")
    public R getExperienceList() {
        try {
            return R.success(webService.getExperienceList());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @PostMapping("/webInsertStudent")
    public R webInsertStudent(@RequestBody Student student) {
        try {
            webService.webInsertStudent(student);
            return R.success();
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    @GetMapping("/getClassroom")
    public R getClassroom() {
        try {
            return R.success(webService.getClassroom());
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }
}
